class OrderController < ApplicationController

  before_filter :verify_session

  def create
    order = Order.new
    order.book_id = params[:id].to_i
    order.reader_id = session[:user].id
    order.status=OrderStatus::WAIT_PERMIT
    if order.save
      email = BookMailer.create_reserveSuccess(order)
      BookMailer.deliver(email)
      flash[:notice] = '预定成功,请等待管理员批准'
    else
      flash[:notice] = '预定失败'
    end
    redirect_to :controller=>'out',:action=>'search'
  end
  
  def list
    @orders_pages, @orders = paginate :orders, :per_page => 10
  end
  
  def reject
    @order = Order.find(params[:id])
    if @order.destroy
      
    end
    redirect_to :action => 'list'
  end
end
